package Apps;

import Dao.UntilHive;

import java.sql.SQLException;
import java.sql.Connection;
import java.sql.Statement;

public class CreateTable {
    private static String driverName = "org.apache.hive.jdbc.HiveDriver";



    public void createTable(String tableName){
        Connection connection = UntilHive.getCon();
        Statement statement = null;
        try {
            statement = connection.createStatement();
            String sql = "CREATE TABLE "+tableName+" ( eid int, name String, "
                    +" salary String, destignation String)"
                    +" COMMENT 'Employee details'"
                    +" ROW FORMAT DELIMITED"
                    +" FIELDS TERMINATED BY '\t'"
                    +" LINES TERMINATED BY '\n'"
                    +" STORED AS TEXTFILE";
            statement.execute(sql);
            System.out.println("Database userdb created successfully.");

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            UntilHive.closeAll(connection, statement, null);
        }
    }

    public static void main(String[] args)  {
        new CreateTable().createTable("u_data");
    }
}
